using System;

namespace LS.Digitize
{
    public abstract class PrimitiveSerializer : Serializer, IPrimitiveSerializer
    {
        public override bool IsPrimitive => true;
        public PrimitiveSerializer(Type type) : base(type)
        {
            
        }
    }

    public abstract class PrimitiveSerializer<T> : PrimitiveSerializer, IPrimitiveSerializer<T>
    {
        public PrimitiveSerializer() : base(typeof(T))
        {
        }

        public override object Read(IReader reader)
        {
            return ReadData(reader);
        }

        public override void Write(IWriter writer, object obj)
        {
            WriteData(writer, (T)obj);
        }

        public abstract void WriteData(IWriter writer, T obj);
        public abstract T ReadData(IReader reader);
    }

}